import cv2

# OpenCV的逻辑运算-- 与或非 异或
# OpenCV中的逻辑运算就是对应位置元素进行与或非，异或。
#
# res = 204 & 213
#
# print(res)
# res = 204 | 213
#
# print(res)
# # opencv中的非， 0 反过来就是255
# res = ~255
# # res = ~0
#
# print(res)
# res = 204 ^ 213
#
# print(res)

cat = cv2.imread('./images/cat.jpg')
dog = cv2.imread('./images/dog.jpg')
new_cat = cv2.resize(cat, (dog.shape[:-1][::-1]))

# 非操作,相当于 255 - cat
# cat_not = cv2.bitwise_not(cat)
# cv2.imshow('not_cat', cat_not)

# 与操作,相当于对应元素与操作
# cat_and = cv2.bitwise_and(new_cat, dog)
# cv2.imshow('and_cat', cat_and)

# 或操作,相当于对应元素或操作
# cat_and = cv2.bitwise_or(new_cat, dog)
# cv2.imshow('or_cat', cat_and)

# 异或操作,相当于对应元素异或操作
cat_and = cv2.bitwise_xor(new_cat, dog)
cv2.imshow('xor_cat', cat_and)

cv2.waitKey(0)
cv2.destroyAllWindows()
